unit uProfileXml;

interface
uses
  Classes, XMLIntf, msxmldom, XMLDoc, xmldom, SysUtils, msxml, dialogs;

type
  Tavset_rec = record
    FileExt  : string;
    vencoder : string;
    vsize    : string;
    vfrate   : string;
    vbrate   : string;
    aencoder : string;
    asrate   : string;
    achannel : string;
    abrate   : string;

    vencoder_index : string;
    vsize_index    : string;
    vfrate_index   : string;
    vbrate_index   : string;
    aencoder_index : string;
    asrate_index   : string;
    achannel_index : string;
    abrate_index   : string;

  end;

Type
  TProfileXml = class

  private
    myxml: TXMLDocument;
    Favset_rec: Tavset_rec;
    procedure Setavset_rec(const Value: Tavset_rec);
    procedure init();

  public
    constructor create(filepath: string);

    property avset_rec : Tavset_rec read Favset_rec write Setavset_rec;
  end;

implementation

constructor TProfileXml.create(filepath: string);
begin
  myxml := TXMLDocument.Create(filepath);
  init();
end;

procedure TProfileXML.init();
var
  node, temp_node : IDOMNode;
  i : Integer;
begin
  node := myxml.DOMDocument.documentElement.firstChild;
  Favset_rec.FileExt := node.attributes.getNamedItem('FileExt').nodeValue;

  node := node.nextSibling;

  for i:=0 to node.childNodes.length-1 do
  begin
    temp_node := node.childNodes[i];
    if temp_node.nodeName = 'AudioCodecName' then
    begin
      Favset_rec.aencoder := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.aencoder_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end
    else if temp_node.nodeName = 'AudioBitrate' then
    begin
      Favset_rec.abrate := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.abrate_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end
    else if temp_node.nodeName = 'SampleRate' then
    begin
      Favset_rec.asrate := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.asrate_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end
    else if temp_node.nodeName = 'Channel' then
    begin
      Favset_rec.achannel := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.achannel_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end
    else if temp_node.nodeName = 'VideoCodecName' then
    begin
      Favset_rec.vencoder := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.vencoder_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end
    else if temp_node.nodeName = 'Size' then
    begin
      Favset_rec.vsize := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.vsize_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end
    else if temp_node.nodeName = 'FrameRate' then
    begin
      Favset_rec.vfrate := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.vfrate_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end
    else if temp_node.nodeName = 'VideoBitrate' then
    begin
      Favset_rec.vbrate := temp_node.attributes.getNamedItem('DefValue').nodeValue;
      Favset_rec.vbrate_index := temp_node.attributes.getNamedItem('DefID').nodeValue;
    end;
  end;
end;


procedure TProfileXml.Setavset_rec(const Value: Tavset_rec);
begin
  Favset_rec := Value;
end;

end.
